const path = require("path");
module.exports = {
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          // If you are using less-loader@5 please spread the lessOptions to options directly
          modifyVars: {},
          javascriptEnabled: true,
        },
      },
    },
  },
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true,
      builderOptions: {
        productName: "electron-vue-ant",
        appId: "com.electron.app",
        copyright: "Copyright ©2020 Yourwebsite.com",
        directories: {
          output: "build",
        },
        mac: {
          identity: "com.electron.app",
          target: ["dmg"],
          artifactName: "${productName}.${ext}",
          icon: "src/assets/appicon.icns",
        },
        dmg: {
          title: "${productName}",
          artifactName: "${productName}.${ext}",
          icon: "src/assets/appicon.icns",
        },
        win: {
          verifyUpdateCodeSignature: false,
          legalTrademarks: "Copyright ©2020 Yourwebsite.com",
          publisherName: "electron-vue-ant",
          requestedExecutionLevel: "highestAvailable",
          target: [
            {
              target: "nsis",
              arch: ["ia32"],
            },
          ],
          artifactName: "${productName}.${ext}",
          icon: "src/assets/appicon.ico",
        },
        nsis: {
          oneClick: false,
          allowToChangeInstallationDirectory: true,
          perMachine: true,
          allowElevation: true,
          artifactName: "${productName}-V${version}.${ext}",
          runAfterFinish: true,
          shortcutName: "electron-vue-ant",
        },
        publish: [
          {
            provider: "generic",
            url: "http://electron.org/update/",
          },
        ],
      },
    },
  },
  chainWebpack: (config) => {
    const svgRule = config.module.rule("svg");
    // 清除已有的所有 loader,否则接下来的 loader 会附加在该规则现有的 loader 之后。
    svgRule.uses.clear();
    svgRule
      .test(/\.svg$/)
      .include.add(path.resolve(__dirname, "./src/assets/images")) // 配置icons的目录
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
        symbolId: "icon-[name]",
      });
    const fileRule = config.module.rule("file");
    fileRule.uses.clear();
    fileRule
      .test(/\.svg$/)
      .exclude.add(path.resolve(__dirname, "./src/assets/images")) // 配置icons的目录
      .end()
      .use("file-loader")
      .loader("file-loader");
  },
};
